<?php
namespace app\api\controller;

use think\Db;
class Banner
{
    /**
     * @api {get} api\banner\banner 获取轮播图
     * @apiGroup Group
     * @apiDescription 获取轮播图
     * @apiSuccess {int} id 轮播图id
     * @apiSuccess {String} image 轮播图
     * @apiSuccess {String} url 轮播图url
     * @apiSuccess {String} url 图片加载失败时的文字
     * @apiSuccessExample 数据:
     * {
    "code": 200,
    "msg": "请求成功",
    "data": [
    {
    "id": 2,
    "image": "\\uploads\\banner\\banner_img\\20201223\\667536b468654b1ffd6be32102825a69.jpg",
    "url": "list-4.html",
    "title": "加载失败"
    },
     */
    public function banner(){
        $data=Db::name('banner')
            ->field('id,image,url,title')
            ->order('sort asc')
            ->select();

        if($data){
            return json(['code'=>200,'msg'=>"请求成功",'data'=>$data]);
        }else{
            return json(['code'=>0,'msg'=>"请求失败"]);
        }
    }

}